let app = getApp()
Component({
    properties: {
         linkurl:String,
         img_id:Number,
         pageid:Number,
         order_type:Number,
         good_type:Number,
         params:Object,
         styleType:String,
         page_type:String,
         pagetitle:String,
         type:String,
         tab:Number,
         cancel:Number,
         id:Number,
         index:Number,
         content_type:Number,
         orderStatusCur:Number,
         orderid:Number,
         activity:String,
         activity_id:Number,
         goods_id:Number,
         productlist:Array,
         CardInfo:Array,
         distribution_id:Number,
         layer_num:Number
      },
      data:{  
        cartCount:0,
        buy_num:1
      },
    lifetimes: {
        attached: function () {
              var type=this.data.type;
              if(this.data.pagetitle=='')
              {
                var pagetitle='';
                switch(type){
                  case 'comment':
                    pagetitle='发表评价';
                    break;
                  case 'live_agreement':
                    pagetitle='服务协议';
                    break;
                  case 'pointsdetails':
                    pagetitle='积分明细';
                    break;
                  case 'exchangerecord':
                    pagetitle='兑换记录';
                    break;
                  case 'series_detail':
                    pagetitle='专栏详情';
                    break;
                  case 'series_list':
                    pagetitle='专栏列表';
                    break;
                  case 'course_detail':
                    pagetitle='内容详情';
                    break;
                  case 'mine_order':
                    pagetitle='我的订单';
                    break;
                  case 'express':
                      pagetitle='物流信息';
                      break;
                  case 'order_detail':
                      pagetitle='订单详情';
                      break;
                  case 'services_order_info':
                        pagetitle='预约详情';
                        break;
                  case 'services_order':
                          pagetitle='预约详情';
                          break;
                  case 'information':
                      pagetitle='修改信息';
                      break;
                  case 'good_detail':
                        pagetitle='商品详情';
                        break;
                  case 'shop_car':
                          pagetitle='购物车';
                          break;
                  case 'collection':
                          pagetitle='我的收藏';
                          break;
                  case 'coupon':
                            pagetitle='我的优惠券';
                            break;
                  case 'page_apply_distribution':
                            pagetitle='申请';
                            break;
                  case 'page_distribution':
                              pagetitle='佣金中心';
                            break;
                  case 'page_dist':
                              pagetitle='佣金中心';
                            break;
                   case 'bargain_detail':
                              pagetitle='砍价详情';
                            break;
                  case 'course_list':
                              pagetitle='内容列表';
                            break;
                }
              }else{
                var pagetitle=this.data.pagetitle;
              }
              if(this.data.type=='collection')
              {
                pagetitle='我的收藏';
              }
              if(this.data.type=='coupon')
              {
                pagetitle='我的优惠券';
              }
              if(this.data.type=='page_dist')
              {
                pagetitle='佣金中心';
              }
              if(this.data.type=='choose_account_type')
              {
                pagetitle='选择账户类型';
              }
              if(this.data.type=='page_applyCw')
              {
                pagetitle='提现申请';
              }
              if(this.data.type=='bargain_record')
              {
                pagetitle='帮砍记录';
              }
              if(this.data.type=='page_coupon_list')
              {
                pagetitle='优惠券列表';
              }
              if(this.data.type=='page_integral_mall'||this.data.type==='integral_mall')
              {
                pagetitle='积分商城';
              }
              if(this.data.type=='goods_list'||this.data.type==='page_good_list'||this.data.type==='page_goods_list')
              {
                if(pagetitle==''){
                  pagetitle='商品列表';
                }
              }
              if(this.data.type=='services_order_create')
              {
                pagetitle='提交订单';
              }
              if(this.data.type=='search')
              {
                pagetitle='搜索';
              }
              if(this.data.type=='bargain_list')
              {
                pagetitle='砍价';
              }
              if(this.data.type=='seckill_list')
              {
                pagetitle='秒杀列表';
              }
              if(this.data.type=='page_addCard')
              {
                pagetitle='添加新账户';
              }
              if(this.data.type=='group_list')
              {
                pagetitle='拼团';
              }
              if(this.data.type=='pay_result')
              {
                pagetitle='购买结果';
              }
              if(this.data.type=='phone'||this.data.type=='chat')
              {
                pagetitle='联系客服';
              }
              if(this.data.type=='selfaddress')
              {
                pagetitle='自提点列表';
              }
              if(this.data.type=='address')
              {
                pagetitle='收货地址列表';
              }
              if(this.data.type=='confirm_order')
              {
                pagetitle='确认订单';
              }
              if(this.data.type=='mine_course')
              {
                pagetitle='我的课程';
              }
            
              if(this.data.type=='distribution_agreement')
              {
                pagetitle='申请协议';
              }
              if(this.data.type=='mine_evaluate')
              {
                pagetitle='我的评价';
              }
              if(this.data.type=='services_order_list'&&this.data.page_type==5)
              {
                pagetitle='我的预约';
              }
              if(this.data.type=='mine_order'&&this.data.page_type==4)
              {
                pagetitle='我的拼团';
              }
              if(this.data.type=='mine_order'&&this.data.page_type==2)
              {
                pagetitle='我的砍价';
              }
              if(this.data.type=='mine_order'&&this.data.page_type==3)
              {
                pagetitle='我的秒杀';
              }
              wx.setNavigationBarTitle({
                title:pagetitle
              })
        }
      },
   
    methods: {
 
      messageinfo:function(e){
        this.setData({
          messageInfo:e.detail
        })
      },
      editmessage:function(e){
        this.setData({ 
          messageInfo:e.detail
        })
      },
      virtualcardinfo:function(e){
          var spec=[];
          spec.push(e.detail)
          this.setData({
             CardInfo:spec
          })
      },
      nowbuy:function(e){
        wx.setStorageSync('confirmorder',e.detail)
        wx.navigateTo({ 
          url: '/yb_shopv2/native/all/index?type=confirm_order&type_id=0',
       })
      },
      changecacrt:function(e){ 
        this.setData({
          cartCount:e.detail
        })
      },
      ongoodsevent:function() {
      },
      change_share:function(e){
        var sharepath='/yb_shopv2/entry/video-market/index';
        if(typeof(e.detail.id)!='undefined'){
          sharepath='/yb_shopv2/entry/video-market/index?id='+e.detail.id;
        }
        this.setData({
          sharedesc:e.detail.desc,
          sharetitle:e.detail.title,
          sharecover:e.detail.cover,
          shareid:e.detail.id,
          sharepath:sharepath
        })
      },
      onShareAppMessage: function (e) {
        return console.log(e, "页面内按钮分享"), {
          desc:typeof(this.data.sharedesc)!='undefined'?this.data.sharedesc:'',
          title:typeof(this.data.sharetitle)!='undefined'?this.data.sharetitle:'',
          imageUrl:typeof(this.data.sharecover)!='undefined'?this.data.sharecover:'',
          path:typeof(this.data.sharepath)!='undefined'?this.data.sharepath:'/yb_shopv2/entry/video-market/index'
        };
      },
      get_goodsid:function(e){
           this.setData({ 
            activity_id:e.detail.activity_id,
            cart_id:e.detail.cart_id,
            buy_page:e.detail.buy_page,
            spec_id_group:e.detail.spec_id_group,
            goodsid:e.detail.goodId,
            buy_num:e.detail.buy_num,
            timestamp:Date.parse(new Date()),
            buy_type:e.detail.buy_type
           })
      }
    }
});
